<?php
include_once 'ns_include.php';
include_once 'subapplication.class.php';


class CreateSoftwareDescription extends subapplication
{
    private $cmd;
    public static $PROTOCOL = "CreateSoftwareDescription";

    public static function create(command $cmd)
    {
        if (!self::IsThisClass($cmd)) return null;

        $N = new CreateSoftwareDescription($cmd);
        return $N;
    }

    private $description = null;
    private $name = null;

    public function __construct(command $cmd)
    {
        $this->cmd  = $cmd;
        $this->name = $cmd->GetData('Name');
        $this->description = $cmd->GetData('Description');
    }

    public function execute()
    {
        $S = SoftwareDescription::createFromCommand($this->cmd);

        $worked = ns_dao::CreateSoftwareDescription($S);

        if ($worked)
            $this->UpdateResult('yes you were able to send data  the server '.$S);
        else
            $this->UpdateResult('Failed to create softare desc');

        
    }


    public function result()
    {
        $this->cmd->GetResult();
    }

    public function UpdateResult($str)
    {
        $this->cmd->SetResult($str);
    }



    /*
     * check to see if command is a UPLOAD
     */
    public static function IsThisClass(command $cmd)
    {

        if (!$cmd->HasDataKey('Name')) return false;
        if (!$cmd->HasDataKey('Description')) return false;


        return true;
    }

    public static $STAGE_START = "START";
    public static $STAGE_DESCRIBE = "DESCRIBE";

}

?>
